package com.example.service;


import com.example.entity.*;
import com.example.mapper.HotelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Date;
import java.util.List;

@Service
public class HotelServiceImp implements HotelService{

    @Autowired
    private HotelMapper hotelMapper;


    //房间
    @Override
    public List<Room> queryRoom() {
        List<Room> rooms = hotelMapper.queryRoom();
        return rooms;
    }

    @Override
    public List<User> queryUs() {
        List<User> users = hotelMapper.queryUs();
        return users;
    }

    @Override
    public List<Ud> queryDd() {
        List<Ud> uds = hotelMapper.queryDd();
        return uds;
    }

    @Override
    public List<Fjh> queryFj() {
        List<Fjh> fjhs = hotelMapper.queryFj();
        return fjhs;
    }

    //轮播图
    @Override
    public List<Lunbo> queryLun() {
        List<Lunbo> lunbos = hotelMapper.queryLun();
        return lunbos;
    }

    //根据id返回房间信息
    @Override
    public List<Room> queryRid(Integer id) {
        List<Room> rooms  = hotelMapper.queryRid(id);
        return rooms;
    }

    @Override
    public List<Fjh> queryF(Integer id) {
        List<Fjh> fjh=hotelMapper.queryF(id);
        return fjh;
    }


    @Override
    public int updateF(Fjh fjh) {
        int i = hotelMapper.updateF(fjh);
        return i;
    }

    @Override
    public User queryU(String name) {
        User user = hotelMapper.queryU(name);
        return user;
    }

    @Override
    public int insertUd(String danf, String uid, Date ru, Date tui, String day, String pri,String rooname) {
        int i = hotelMapper.insertUd(danf, uid, ru,tui,day,pri,rooname);
        return i;
    }


    @Override
    public List<Ud> queryUd(String uid) {
        List<Ud> uds = hotelMapper.queryUd(uid);
        return uds;
    }

    @Override
    public int updateR(String state, String fh) {
        int i = hotelMapper.updateR(state, fh);
        return i;
    }

    @Override
    public int insertU(User user) {
        int i=0;
        if(user.getName()=="" || user.getPassword()==""){
           return i;
        }else {
            i = hotelMapper.insertU(user);
        }

        return i;
    }

    @Override
    public int deletU(Integer id) {
        int i = hotelMapper.deletU(id);
        return i;
    }

    @Override
    public int deletR(Integer id) {
        int i = hotelMapper.deletR(id);
        return i;
    }

    @Override
    public int deletF(Integer id) {
        int i = hotelMapper.deletF(id);
        return i;
    }

    @Override
    public int deletD(Integer id) {
        int i = hotelMapper.deletD(id);
        return i;
    }

    @Override
    public int insertUu(User user) {
        int i=0;
        if(user.getName()=="" || user.getPassword()=="" || user.getPerms()==""){
            return i;
        }else {
            i = hotelMapper.insertUu(user);
        }
        return i;
    }

    @Override
    public int insertR(Room room) {

        int i=0;
        if(room.getRoomname()=="" || room.getImg()=="" || room.getLou()==""|| room.getMianji()==""
                || room.getNum()==null|| room.getS()==""|| room.getSs()==""|| room.getSss()==""
                || room.getTitl()==""|| room.getTitll()==""||room.getPrice()==""){
            return i;
        }else {
            i =hotelMapper.insertR(room);
        }
        return i;


    }

    @Override
    public int insertF(Fjh fjh) {

        int i=0;
        if(fjh.getFh()=="" || fjh.getRid()=="" ){
            return i;
        }else {
            i = hotelMapper.insertF(fjh);
        }
        return i;
    }
/*
    @Override
    public int updateU(User user) {
        int i =0;
        if(user.getName()=="" || user.getPassword()=="" || user.getPerms()==""){
            return i;
        }else {
            i = hotelMapper.updateU(user);
        }
        return i;
    }*/

    @Override
    public List<User> selectUU(Integer id) {
        List<User> users = hotelMapper.selectUU(id);
        return users;
    }
    @Override
    public int updateUU(User user) {
        int i=0;
        if(user.getName()=="" || user.getPassword()=="" || user.getPerms()==""){
            return i;
        }else {
            i = hotelMapper.updateUU(user);
        }
        return i;

    }

    @Override
    public List<Room> selectRRr(Integer id) {
        List<Room> rooms = hotelMapper.selectRRr(id);
        return rooms;
    }

    @Override
    public int updateRR(Room room) {

        int i=0;
        if(room.getRoomname()=="" || room.getImg()=="" || room.getLou()==""|| room.getMianji()==""
                || room.getNum()==null|| room.getS()==""|| room.getSs()==""|| room.getSss()==""
                || room.getTitl()==""|| room.getTitll()==""||room.getPrice()==""){
            return i;
        }else {
            i =hotelMapper.updateRR(room);
        }
        return i;

    }

    @Override
    public List<Ud> selectUId(Integer id) {
        List<Ud> uds = hotelMapper.selectUId(id);

        return uds;
    }
}
